package cn.iocoder.yudao.module.biz.dal.mysql.contract.autocode;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.biz.controller.admin.contract.autocode.rule.vo.AutoCodeRulePageReqVO;
import cn.iocoder.yudao.module.biz.dal.dataobject.contract.autocode.AutoCodeRuleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 编码生成规则 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface AutoCodeRuleMapper extends BaseMapperX<AutoCodeRuleDO> {
    default PageResult<AutoCodeRuleDO> selectPage(AutoCodeRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AutoCodeRuleDO>()
                .eqIfPresent(AutoCodeRuleDO::getRuleCode, reqVO.getRuleCode())
                .likeIfPresent(AutoCodeRuleDO::getRuleName, reqVO.getRuleName())
                .eqIfPresent(AutoCodeRuleDO::getRuleLength, reqVO.getRuleLength())
                .eqIfPresent(AutoCodeRuleDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AutoCodeRuleDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(AutoCodeRuleDO::getCreateDept, reqVO.getCreateDept())
                .betweenIfPresent(AutoCodeRuleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AutoCodeRuleDO::getRemark, reqVO.getRemark())
                .orderByDesc(AutoCodeRuleDO::getRuleId));
    }
}